package 
{
import as3.UserInfoEvent;
import as3.UserInfoDialog;
import as3.ShopDialog;
import as3.Subject;

import flash.display.Sprite;


public class Main extends Sprite
{
	public function Main()
	{
		///////as
		var subject:Subject = new Subject();
		
		var shopDialog:ShopDialog = new ShopDialog();
		var userInfoDialog:UserInfoDialog = new UserInfoDialog();
		
		//放在具体的业务逻辑处理的地方
		subject.addEventListener(UserInfoEvent.USER_INFO_CHANGE, function(e:UserInfoEvent):void
		{
			shopDialog.onUserInfoChange(e);
			userInfoDialog.onUserInfoChange(e);
		});
		
		
		///////pull
//		var subject:UserInfoSubject = new UserInfoSubject();
//		subject.registerObserver(new UserInfoObserver_UserInfoDialog(subject));
//		subject.registerObserver(new UserInfoObserver_ShopInfoDialog(subject));
		
		///////push
//		var subject:UserInfoSubject = new UserInfoSubject();
//		subject.registerObserver(new UserInfoObserver_ShopInfoDialog());
//		subject.registerObserver(new UserInfoObserver_UserInfoDialog());
		
		//开始发布主题
		subject.setData({"userName": "zhangSan", "level":4, "golden":1000});
		subject.setData({"userName": "liSi", "level":40, "golden":120000});
		subject.setData({"userName": "wangWu", "level":3, "golden":800});
	}
}
}
